package com.zhengshang.web.controller.app;

import com.zhengshang.api.domain.AppThirdColumnCategory;
import com.zhengshang.api.service.IAppThirdColumnCategoryService;
import com.zhengshang.common.annotation.Log;
import com.zhengshang.common.core.controller.BaseController;
import com.zhengshang.common.core.domain.AjaxResult;
import com.zhengshang.common.core.page.TableDataInfo;
import com.zhengshang.common.enums.BusinessType;
import com.zhengshang.common.utils.poi.ExcelUtil;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.web.bind.annotation.*;

import java.util.List;
import java.util.Map;

/**
 * 影音分类Controller
 *
 * @author zhengshang
 * @date 2022-04-11
 */
@RestController
@RequestMapping("/app/thirdColumnCategory")
public class AppThirdColumnCategoryController extends BaseController {
    @Autowired
    private IAppThirdColumnCategoryService appThirdColumnCategoryService;

    /**
     * 查询影音分类列表
     */
    @PreAuthorize("@ss.hasPermi('app:category:list')")
    @GetMapping("/list")
    public TableDataInfo list(AppThirdColumnCategory appThirdColumnCategory) {
        startPage();
        List<Map<String, Object>> list = appThirdColumnCategoryService.selectAppThirdColumnCategoryList1(appThirdColumnCategory);
        return getDataTable(list);
    }

    /**
     * 查询影音分类列表
     */
    @GetMapping("/queryList")
    public AjaxResult queryList(AppThirdColumnCategory appThirdColumnCategory) {
        List<AppThirdColumnCategory> list = appThirdColumnCategoryService.selectAppThirdColumnCategoryList(appThirdColumnCategory);
        return AjaxResult.success(list);
    }

    /**
     * 导出影音分类列表
     */
    @PreAuthorize("@ss.hasPermi('app:category:export')")
    @Log(title = "影音分类", businessType = BusinessType.EXPORT)
    @GetMapping("/export")
    public AjaxResult export(AppThirdColumnCategory appThirdColumnCategory) {
        List<AppThirdColumnCategory> list = appThirdColumnCategoryService.selectAppThirdColumnCategoryList(appThirdColumnCategory);
        ExcelUtil<AppThirdColumnCategory> util = new ExcelUtil<AppThirdColumnCategory>(AppThirdColumnCategory.class);
        return util.exportExcel(list, "category");
    }

    /**
     * 获取影音分类详细信息
     */
    @PreAuthorize("@ss.hasPermi('app:category:query')")
    @GetMapping(value = "/{thirdColumnCategoryId}")
    public AjaxResult getInfo(@PathVariable("thirdColumnCategoryId") Long thirdColumnCategoryId) {
        return AjaxResult.success(appThirdColumnCategoryService.selectAppThirdColumnCategoryById(thirdColumnCategoryId));
    }

    /**
     * 新增影音分类
     */
    @PreAuthorize("@ss.hasPermi('system:category:add')")
    @Log(title = "影音分类", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody AppThirdColumnCategory appThirdColumnCategory) {
        return toAjax(appThirdColumnCategoryService.insertAppThirdColumnCategory(appThirdColumnCategory));
    }

    /**
     * 修改影音分类
     */
    @PreAuthorize("@ss.hasPermi('app:category:edit')")
    @Log(title = "影音分类", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody AppThirdColumnCategory appThirdColumnCategory) {
        return toAjax(appThirdColumnCategoryService.updateAppThirdColumnCategory(appThirdColumnCategory));
    }

    /**
     * 删除影音分类
     */
    @PreAuthorize("@ss.hasPermi('app:category:remove')")
    @Log(title = "影音分类", businessType = BusinessType.DELETE)
    @DeleteMapping("/{thirdColumnCategoryIds}")
    public AjaxResult remove(@PathVariable Long[] thirdColumnCategoryIds) {
        return toAjax(appThirdColumnCategoryService.deleteAppThirdColumnCategoryByIds(thirdColumnCategoryIds));
    }
}
